using ApiDemo.Domain.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using ApiDemo.Infrastructure.Persistence.Configuration.Base;

namespace ApiDemo.Infrastructure.Persistence.Configuration
{
    public class BlogConfiguration : BaseEntityConfiguration<Blog>
    {
        public override void Configure(EntityTypeBuilder<Blog> builder)
        {
            base.Configure(builder);

            //设置表名，查了老半天才查到原来设置表名方法是这个，残念。。。熬了个大夜
            builder.ToTable("blog");

            builder.Property(x => x.Title).HasColumnName("title").HasMaxLength(200).HasColumnOrder(1);
            builder.Property(x => x.BlogContent).HasColumnName("blog_content").HasMaxLength(2000).HasColumnOrder(2);
        }
    }
}